package cn.elricyu.tt.util;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

public final class MessageFactory {

	static ResourceBundle resourceBundle;
	
	static final String bundleName = "kf";
	
	static {
		try {
			resourceBundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
		} catch (Throwable e) {
			resourceBundle = ResourceBundle.getBundle(bundleName, Locale.CHINA);
		}
	}
	
	public static String getMessage(String id,Object...objs){
		if(id == null ) return "";
		String str = resourceBundle.getString(id);
		if(str == null ) return "";
		if(objs == null || objs.length == 0) return str;
		return MessageFormat.format(str, objs);
	}
	
	public static String getMessage(String id){
		if(id == null ) return "";
		String format = resourceBundle.getString(id);
		if(format == null ) return "";
		return format;
	}
	
	
}
